home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CU Amiga Super CD-ROM 15
/
CU Amiga Magazine's Super CD-ROM 15 (1997)(EMAP Images)(GB)[!][issue 1997-10].iso
/
ShapeShifter
/
VideoDrivers
/
RetinaZ2
/
Source
/
RetinaZ2mapped.asm
< prev
next >
Wrap
Assembly Source File
|
1996-05-06
|
8KB
|
377 lines
*
* ShapeShifter external video driver for Retina Z2
*
* $VER: RetinaZ2mapped.asm 1.1 (3.5.96)
*
* Christoph Niedeggen 24.12.95-30.12.95
* based on code by Christian Bauer
*
* History:
*
* V1.1 : Patch to remove a bug in Retina_OpenScreen parameters,
* provided by Christophe Labouisse <labouiss@sncf.fr>
* V1.0 : First Release version.
MACHINE 68020
INCLUDE "exec/types.i"
INCLUDE "exec/macros.i"
INCLUDE "exec/memory.i"
INCLUDE "intuition/intuition.i"
INCLUDE "utility/tagitem.i"
INCLUDE "exec/alerts.i"
INCLUDE "libraries/retina.i"
INCLUDE "libraries/retina_lib.i"
INCLUDE "shapeextvideo.i"
*
* Offset for linear mapped RetinaZ2 RAM
*
C_RL_START equ $01c00000
*
* Definition of our private context structure for storing local variables
*
STRUCTURE MyContext,0
APTR conIntuitionBase
APTR conRetinaBase
APTR conScreen ;The screen
APTR conRetinaScr ;The screen's RetinaScreen
STRUCT conRGBBuf,256*3 ;Buffer for LoadRGB32
WORD conVideoMode ;Video mode (VMODE_*)
LABEL MyContext_SIZEOF
*
* This is the driver header
*
EVHEADER DriverTags
*
* The header tags that describe the driver and provide pointers to
* the driver's routines
*
DriverTags dc.l SHEV_Level,1 ;Interface level 1
dc.l SHEV_Version,0
dc.l SHEV_Revision,1
dc.l SHEV_Name,DriverName
dc.l SHEV_ID,DriverID
dc.l SHEV_Author,DriverAuthor
dc.l SHEV_OpenScreen,MyOpenScreen
dc.l SHEV_CloseScreen,MyCloseScreen
dc.l SHEV_LoadRGB32,MyLoadRGB32
dc.l SHEV_Refresh,MyRefresh
dc.l TAG_END,0
DriverName dc.b "Retina Z2 mapped Driver",0
CNOP 0,4
DriverID dc.b "$VER: RetinaZ2mapped 1.0 (30.12.95)",13,10,0
CNOP 0,4
DriverAuthor dc.b "Christoph Niedeggen",0
CNOP 0,4
*
* The OpenScreen routine
* a0: Taglist with input parameters
* a1: Taglist with output parameters
* a6: Base of utility.library
*
MyOpenScreen movem.l d2-d7/a2-a6,-(sp)
move.l a0,a4 ;a4: Input taglist
move.l a1,a5 ;a5: Output taglist
move.l a6,_UtilityBase
move.l (4).w,_ExecBase
; Allocate memory for context
move.l _ExecBase,a6
move.l #MyContext_SIZEOF,d0
move.l #MEMF_PUBLIC|MEMF_CLEAR,d1
JSRLIB AllocVec
tst.l d0
beq OpenFailed
move.l d0,a2 ;a2: Context
; Open intuition.library
move.l _ExecBase,a6
lea IntuitionName,a1
moveq #37,d0
JSRLIB OpenLibrary
move.l d0,conIntuitionBase(a2)
beq OpenFailed
; Open retina.library
move.l _ExecBase,a6
lea RetinaName,a1
moveq #0,d0
JSRLIB OpenLibrary
move.l d0,conRetinaBase(a2)
beq OpenFailed
; Store context pointer in output taglist
move.l _UtilityBase,a6
move.l a5,a0
move.l #SHEV_Context,d0
JSRLIB FindTagItem
move.l d0,a0
move.l a2,ti_Data(a0)
; Get video mode and set the refresh type and screen depth accordingly
; This driver only supports VMODE_8BIT
move.l _UtilityBase,a6
move.l a4,a0
move.l #SHEV_VideoMode,d0
moveq #VMODE_1BIT,d1 ;Dummy default
JSRLIB GetTagData
move.w d0,conVideoMode(a2)
cmp.l #VMODE_8BIT,d0
bne OpenFailed
move.l a5,a0
move.l #SHEV_RefreshType,d0
JSRLIB FindTagItem
tst.l d0
beq 10$
move.l d0,a1
move.l #RTYPE_CUSTOM,ti_Data(a1) ;to get Vector at $8 patched
10$
; Extract screen parameters from input taglist
move.l _UtilityBase,a6
move.l a4,a0
move.l #SHEV_ScreenX,d0
moveq #0,d1
JSRLIB GetTagData
move.l d0,ScrWidth
move.l a4,a0
move.l #SHEV_ScreenY,d0
moveq #0,d1
JSRLIB GetTagData
move.l d0,ScrHeight
; Open the screen and store pointer in output taglist
move.l ScrWidth,d0
move.l ScrHeight,d1
moveq #-$1,d2 ;MID_DEFAULT_8
moveq #$0,d3
sub.l a0,a0
move.l conRetinaBase(a2),a6
jsr _LVORetina_OpenScreen(a6)
move.l d0,conRetinaScr(a2)
beq OpenFailed
move.l conIntuitionBase(a2),a6
sub.l a0,a0
lea ScreenTags,a1
JSRLIB OpenScreenTagList
move.l d0,a3 ;a3: Screen
move.l d0,conScreen(a2)
beq OpenFailed
bra ScreenOpened
ScreenOpened move.l _UtilityBase,a6
move.l a5,a0
move.l #SHEV_Screen,d0
JSRLIB FindTagItem
move.l d0,a0
move.l a3,ti_Data(a0)
; Extract all the other data that the caller wants
move.l _UtilityBase,a6
move.l a5,a0
move.l #SHEV_ScreenBase,d0
JSRLIB FindTagItem
tst.l d0
beq 1$
move.l d0,a1
move.l conRetinaScr(a2),a0
move.l _rs_BitMap(a0),a0
move.l a0,d0
add.l #C_RL_START,d0 ;CN24.12.95
move.l d0,ti_Data(a1)
1$
move.l _UtilityBase,a6
move.l a5,a0
move.l #SHEV_BytesPerRow,d0
JSRLIB FindTagItem
tst.l d0
beq 2$
move.l d0,a1
move.l conRetinaScr(a2),a0
moveq #0,d0
move.w _rs_Modulo(a0),d0
move.l d0,ti_Data(a1)
2$
; Everything is OK
movem.l (sp)+,d2-d7/a2-a6
moveq #0,d0
rts
; An error occurred
OpenFailed movem.l (sp)+,d2-d7/a2-a6
moveq #-1,d0
rts
*
* The CloseScreen routine
* a0: Taglist with input parameters
* a1: Taglist with output parameters
* a2: Context pointer (never NULL)
* a6: Base of utility.library
*
MyCloseScreen movem.l d2-d7/a2-a6,-(sp)
; Close the screen
move.l conScreen(a2),d0
beq 1$
move.l d0,a0
move.l conIntuitionBase(a2),a6
JSRLIB CloseScreen
1$
move.l conRetinaScr(a2),d0
beq 2$
move.l d0,a0
move.l conRetinaBase(a2),a6
jsr _LVORetina_CloseScreen(a6)
2$
; Close retina.library
move.l conRetinaBase(a2),d0
beq 3$
move.l d0,a1
move.l _ExecBase,a6
JSRLIB CloseLibrary
3$
; Close intuition.library
move.l conIntuitionBase(a2),d0
beq 6$
move.l d0,a1
move.l _ExecBase,a6
JSRLIB CloseLibrary
6$
; Free context
move.l _ExecBase,a6
move.l a2,a1
JSRLIB FreeVec
CloseDone movem.l (sp)+,d2-d7/a2-a6
moveq #0,d0
rts
*
* The LoadRGB32 routine
* a0: Taglist with input parameters
* a1: Taglist with output parameters
* a2: Context pointer
* a6: Base of utility.library
*
; Get pointer to 32 bit color table
MyLoadRGB32 movem.l d2-d7/a2-a6,-(sp)
move.l a0,a4 ;a4: Input taglist
move.l #SHEV_ColorTable,d0
moveq #0,d1
JSRLIB GetTagData
move.l d0,a0 ;a0: Color table
; Convert to 8 bit color table
lea conRGBBuf(a2),a1
move.w #256*3-1,d1
1$ move.l (a0)+,d0
rol.l #8,d0
move.b d0,(a1)+
dbra d1,1$
; Activate palette
move.l conRetinaBase(a2),a6
move.l conRetinaScr(a2),a0
moveq #0,d0 ;Start with color #0
move.l #256,d1 ;Load 256 colors
lea conRGBBuf(a2),a1
jsr _LVORetina_LoadPalette(a6)
movem.l (sp)+,d2-d7/a2-a6
moveq #0,d0
rts
MyRefresh movem.l a5-a6,-(sp)
move.l (4).w,a6
lea setVBR(pc),a5
jsr -$001e(a6) ;Supervisor()
movem.l (sp)+,a5-a6
rts
setVBR movec.l VBR,a0
move.l $8(a0),$8
rte
*
* Constants
*
; Library names
IntuitionName dc.b "intuition.library",0
GfxName dc.b "graphics.library",0
DOSName dc.b "dos.library",0
RetinaName dc.b "retina.library",0
RetinaEmuName dc.b "retinaemu.library",0
; The name of our screen
ScreenName dc.b "ShapeShifter Screen",0
CNOP 0,4
*
* Data section
*
SECTION "DATA",DATA
; Taglist for OpenScreen()
; Note that it's only safe to use this structure here because
; the SHEV_OpenScreen routine is guaranteed not to be called
; more than once at a time. The buffer for LoadRGB32, however,
; is declared in the Context and not in the BSS segment because
; that routine may be called multiple times for multiple
; screens.
ScreenTags dc.l SA_Depth ;screen with 16x16 pixels, 1 bit
dc.l 1 ;(just to provide intuition screen for input)
dc.l SA_Width
dc.l 16
dc.l SA_Height
dc.l 16
dc.l SA_Quiet,-1
dc.l SA_Title,ScreenName
dc.l TAG_END,0
;values for Retina screen
ScrWidth dc.l 0
ScrHeight dc.l 0
*
* BSS section
*
SECTION "BSS",BSS
; Library base pointers
_ExecBase ds.l 1
_UtilityBase ds.l 1
END